<template>
	<view class="refund-wrapper">
		<block-view paddingTop="24">
			<view class="title">{{ info.status == 1 ? '微信已受理退款' : (info.status == 2 ? '退款成功' : '退款失败') }}</view>
			<template v-if="price_level != false">
				<view class="cost-title">费用明细：</view>
				<view class="cost-item" v-for="(cost, index) in price_level" :key="index">
					<text>{{ cost.name }}：</text>
					<text class="price">¥{{ cost.price }}（{{ cost.num }}份）</text>
				</view>
			</template>
			<view class="refund-list">
				<view class="refund-item">
					<view class="item-title">退款金额</view>
					<text class="item-note">{{ info.price }}</text>
				</view>
				<view class="refund-item">
					<view class="item-title">退款至</view>
					<text class="item-note">微信支付</text>
				</view>
				<!-- <view class="refund-item">
					<view class="item-title">退款受理时间</view>
					<text class="item-note">{{ info.refund_time }}</text>
				</view> -->
				<view class="refund-item">
					<view class="item-title">退款单号</view>
					<text class="item-note">{{ info.refund_no }}</text>
				</view>
			</view>
		</block-view>
		
		<view class="tips">*退款一般需要1-3个工作日才到账，节假日期间退款时间会有延迟，实际到账时间以银行或第三方支付平台账单为准</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				order_id: 0,
				info: {},
				price_level: []
			}
		},
		onLoad(options) {
			this.order_id = options?.order_id || 0
			this.getRefundDetail()
			const eventChannel = this.getOpenerEventChannel()
			eventChannel.on('refundPriceLevel', (data) => {
				// console.log(data);
				this.price_level = JSON.parse(data.price_level)
			})
			
		},
		methods: {
			// 获取退款详情
			async getRefundDetail() {
				const res = await this.$request.get('/api/order/refund_info', {order_id: this.order_id})
				if (res.code == 200) {
					this.info = res.data
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.refund-wrapper {
		padding: 24rpx 30rpx;
		
		.title {
			font-size: 36rpx;
			font-weight: 500;
			color: $uni-color-primary;
			margin-bottom: 48rpx;
		}
		.cost-title {
			color: #262626;
			margin-bottom: 18rpx;
			font-weight: 500;
		}
		.cost-item {
			font-size: 26rpx;
			color: #262626;
			padding: 6rpx 0;
			.price {
				color: #7B7B7B;
			}
			&:last-child {
				padding-bottom: 26rpx;
			}
		}
		.refund-list {
			margin-top: 20rpx;
		}
		.refund-item {
			padding: 22rpx 0;
			color: #666;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-top: 0.5px solid rgba(0,0,0,0.1);
			.item-title {
				color: #262626;
				font-weight: 500;
			}
			.item-note {
				color: #7B7B7B;
			}
			&:last-child {
				padding-bottom: 0;
			}
		}
		
		.tips {
			font-size: 26rpx;
			color: #7B7B7B;
			margin-top: 12px;
		}
	}
</style>